    $(function(){
        $('#setCurrency').jqTransform({imgPath:'jqtransformplugin/img/'});
    });

/*
$(document).ready(function()
{
$('.mnf_sup_list li .right_side p a').each(function() {
var h = $(this).html();
var index = h.indexOf(' ');
if(index == -1) {
index = h.length;
}
$(this).html('<span class="firstWord">' + h.substring(0, index) + '</span>' + h.substring(index, h.length));
});
}); 
*/

    $(document).ready(function(){
        $('#cart_block').hide();
        $('.ajax_add_to_cart_button').hide();
        $('#add_to_cart').hide();
        
        $('#featured_products h4').each(function() {
            var h = $(this).html();
            var index = h.indexOf(' ');
            if(index == -1) {
                index = h.length;
            }
            $(this).html('<span class="firstWord">' + h.substring(0, index) + '</span>' + h.substring(index, h.length));
        });
        
        $('input.comparator').click(function(){
            lst = $('[name="compare_product_list"]');
            lst_str = lst.val();
            check = $(this).is(':checked');
            
            if (check==true){
                //count item current
                temp = lst_str.split(",");
                count=1;
                for ( var i in temp) {
                    if (temp[i].length > 0){
                        count = count + 1;
                    }
                }
                
                if (count <= 2){
                    check_exist = lst_str.indexOf($(this).val());
                    if (check_exist == -1){
                        lst.val(lst.val() + ',' + $(this).val());
                    }                    
                } else {
                    alert("Bạn chỉ có thể so sánh tối đa 2 sản phẩm");
                    $(this).attr('checked', false);
                    return false;
                }
            } else {
                current = lst.val();
                new_str = current.replace($(this).val(), '');
                lst.val(new_str);
            }
            
            //count item current
            temp = lst_str.split(",");
            count=1;
            for ( var i in temp) {
                if (temp[i].length > 0){
                    count = count + 1;
                }
            }
            
            if (count == 2){
                $('#submit_compare').show();
            } else {
                $('#submit_compare').hide();
            }
            
        });
    }); 

    jQuery(document).ready(function(){
    // hide #back-top first
    jQuery("#back-top").hide();
    // fade in #back-top
    jQuery(function () {
        jQuery(window).scroll(function () {
            if (jQuery(this).scrollTop() > 100) {
                jQuery('#back-top').fadeIn();
            } else {
                jQuery('#back-top').fadeOut();
            }
        });

        // scroll body to 0px on click
        jQuery('#back-top a').click(function () {
            jQuery('body,html').animate({
                scrollTop: 0
            }, 800);
            return false;
        });
    });

});